home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
aminet
/
os20
/
cdity
/
yak14a.lha
/
Yak
/
Source
/
popup.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-21
|
10KB
|
311 lines
/*
* Source machine generated by GadToolsBox V2.0b
* which is (c) Copyright 1991-1993 Jaba Development
*
* GUI Designed by : Martin W Scott
*/
#include <exec/types.h>
#include <intuition/intuition.h>
#include <intuition/classes.h>
#include <intuition/classusr.h>
#include <intuition/imageclass.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <graphics/displayinfo.h>
#include <graphics/gfxbase.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/utility_protos.h>
#include <string.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/gadtools_pragmas.h>
#include <pragmas/graphics_pragmas.h>
#include <pragmas/utility_pragmas.h>
#include "popup.h"
struct Screen *Scr = NULL;
UBYTE *PubScreenName = "Workbench";
APTR VisualInfo = NULL;
struct Window *HelpWnd = NULL;
struct Gadget *HelpGList = NULL;
struct Menu *HelpMenus = NULL;
UWORD HelpZoom[4];
struct Gadget *HelpGadgets[23];
UWORD HelpLeft = 0;
UWORD HelpTop = 11;
UWORD HelpWidth = 528;
UWORD HelpHeight = 168;
UBYTE *HelpWdt = NULL;
struct TextAttr *Font, Attr;
UWORD FontX, FontY;
UWORD OffX, OffY;
UBYTE *MBMethod0Labels[] = {
(UBYTE *)"None",
(UBYTE *)"Sprites",
(UBYTE *)"Copper",
NULL };
extern struct MinList hkListView0List;
struct Node hkListView0Nodes[] = {
&hkListView0Nodes[1], ( struct Node * )&hkListView0List.mlh_Head, 0, 0, "Show this window",
&hkListView0Nodes[2], &hkListView0Nodes[0], 0, 0, "Close window",
&hkListView0Nodes[3], &hkListView0Nodes[1], 0, 0, "Zip window",
&hkListView0Nodes[4], &hkListView0Nodes[2], 0, 0, "Shrink window",
&hkListView0Nodes[5], &hkListView0Nodes[3], 0, 0, "Enlarge window",
&hkListView0Nodes[6], &hkListView0Nodes[4], 0, 0, "Activate WBench",
&hkListView0Nodes[7], &hkListView0Nodes[5], 0, 0, "Palette",
&hkListView0Nodes[8], &hkListView0Nodes[6], 0, 0, "PopCommand",
&hkListView0Nodes[9], &hkListView0Nodes[7], 0, 0, "Insert date",
&hkListView0Nodes[10], &hkListView0Nodes[8], 0, 0, "Window cycle",
&hkListView0Nodes[11], &hkListView0Nodes[9], 0, 0, "Screen cycle",
&hkListView0Nodes[12], &hkListView0Nodes[10], 0, 0, "Center screen",
&hkListView0Nodes[13], &hkListView0Nodes[11], 0, 0, "Screen to back",
( struct Node * )&hkListView0List.mlh_Tail, &hkListView0Nodes[12], 0, 0, "Blank display" };
struct MinList hkListView0List = {
( struct MinNode * )&hkListView0Nodes[0], ( struct MinNode * )NULL, ( struct MinNode * )&hkListView0Nodes[13] };
struct NewMenu HelpNewMenu[] = {
NM_TITLE, (STRPTR)"Project", NULL, 0, NULL, NULL,
NM_ITEM, (STRPTR)"Load", (STRPTR)"L", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Save", (STRPTR)"S", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Hide", (STRPTR)"H", 0, 0L, NULL,
NM_ITEM, (STRPTR)"Quit", (STRPTR)"Q", 0, 0L, NULL,
NM_END, NULL, NULL, 0, 0L, NULL };
UWORD HelpGTypes[] = {
STRING_KIND,
LISTVIEW_KIND,
BUTTON_KIND,
BUTTON_KIND,
STRING_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
CHECKBOX_KIND,
STRING_KIND,
STRING_KIND,
STRING_KIND,
CHECKBOX_KIND,
STRING_KIND,
STRING_KIND,
INTEGER_KIND,
INTEGER_KIND,
INTEGER_KIND,
CYCLE_KIND,
CHECKBOX_KIND
};
struct NewGadget HelpNGad[] = {
8, 138, 162, 12, NULL, NULL, GD_KeyStr, 0, NULL, NULL,
8, 17, 161, 120, (UBYTE *)"Yak HotKeys", NULL, GD_hkListView, PLACETEXT_ABOVE|NG_HIGHLABEL, NULL, NULL,
8, 153, 72, 12, (UBYTE *)"Hide", NULL, GD_Hide, PLACETEXT_IN, NULL, NULL,
97, 153, 72, 12, (UBYTE *)"Quit", NULL, GD_Quit, PLACETEXT_IN, NULL, NULL,
284, 3, 235, 12, (UBYTE *)"PopCommand", NULL, GD_PopCLIStr, PLACETEXT_LEFT|NG_HIGHLABEL, NULL, NULL,
185, 110, 26, 11, (UBYTE *)"AutoPoint", NULL, GD_AutoCheck, PLACETEXT_RIGHT, NULL, NULL,
350, 121, 26, 11, (UBYTE *)"Key Activate", NULL, GD_KeyActCheck, PLACETEXT_RIGHT, NULL, NULL,
185, 143, 26, 11, (UBYTE *)"Click To Front", NULL, GD_CTFCheck, PLACETEXT_RIGHT, NULL, NULL,
185, 154, 26, 11, (UBYTE *)"Click To Back", NULL, GD_CTBCheck, PLACETEXT_RIGHT, NULL, NULL,
350, 132, 26, 11, (UBYTE *)"Screen To Back", NULL, GD_ScrCycleCheck, PLACETEXT_RIGHT, NULL, NULL,
350, 154, 26, 11, (UBYTE *)"Wild star", NULL, GD_WildStarCheck, PLACETEXT_RIGHT, NULL, NULL,
350, 143, 26, 11, (UBYTE *)"Screen Activate", NULL, GD_ScrActCheck, PLACETEXT_RIGHT, NULL, NULL,
283, 16, 235, 12, (UBYTE *)"DateFormat", NULL, GD_DateFmt, PLACETEXT_LEFT|NG_HIGHLABEL, NULL, NULL,
283, 29, 235, 12, (UBYTE *)"AutoScreens", NULL, GD_AutoPat, PLACETEXT_LEFT|NG_HIGHLABEL, NULL, NULL,
283, 42, 235, 12, (UBYTE *)"ClickScreens", NULL, GD_ClickPat, PLACETEXT_LEFT|NG_HIGHLABEL, NULL, NULL,
185, 121, 26, 11, (UBYTE *)"AutoPopToFront", NULL, GD_AutoPopCheck, PLACETEXT_RIGHT, NULL, NULL,
283, 55, 235, 12, (UBYTE *)"PopWindows", NULL, GD_PopPat, PLACETEXT_LEFT|NG_HIGHLABEL, NULL, NULL,
284, 68, 235, 12, (UBYTE *)"ClickWindows", NULL, GD_ClickWinPat, PLACETEXT_LEFT|NG_HIGHLABEL, NULL, NULL,
284, 81, 44, 12, (UBYTE *)"ScreenBlank", NULL, GD_ScrTONum, PLACETEXT_LEFT|NG_HIGHLABEL, NULL, NULL,
475, 81, 44, 12, (UBYTE *)"MouseBlankTime", NULL, GD_MouseTONum, PLACETEXT_LEFT|NG_HIGHLABEL, NULL, NULL,
284, 94, 44, 12, (UBYTE *)"ClickVolume", NULL, GD_ClickVol, PLACETEXT_LEFT|NG_HIGHLABEL, NULL, NULL,
411, 94, 108, 12, (UBYTE *)"Method", NULL, GD_MBMethod, PLACETEXT_LEFT|NG_HIGHLABEL, NULL, NULL,
185, 132, 26, 11, (UBYTE *)"RMB Activate", NULL, GD_RMBActCheck, PLACETEXT_RIGHT, NULL, NULL
};
ULONG HelpGTags[] = {
(GTST_MaxChars), 49, (TAG_DONE),
(GTLV_Labels), (ULONG)&hkListView0List, (GTLV_ShowSelected), NULL, (TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(GTST_MaxChars), 255, (TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(TAG_DONE),
(GTST_MaxChars), 49, (TAG_DONE),
(GTST_MaxChars), 99, (TAG_DONE),
(GTST_MaxChars), 99, (TAG_DONE),
(TAG_DONE),
(GTST_MaxChars), 99, (TAG_DONE),
(GTST_MaxChars), 99, (TAG_DONE),
(GTIN_Number), 0, (GTIN_MaxChars), 4, (TAG_DONE),
(GTIN_Number), 0, (GTIN_MaxChars), 4, (TAG_DONE),
(GTIN_Number), 0, (GTIN_MaxChars), 4, (TAG_DONE),
(GTCY_Labels), (ULONG)&MBMethod0Labels[ 0 ], (TAG_DONE),
(TAG_DONE)
};
static UWORD ComputeX( UWORD value )
{
return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
}
static UWORD ComputeY( UWORD value )
{
return(( UWORD )((( FontY * value ) + 4 ) / 8 ));
}
static void ComputeFont( UWORD width, UWORD height )
{
Font = &Attr;
Font->ta_Name = (STRPTR)Scr->RastPort.Font->tf_Message.mn_Node.ln_Name;
Font->ta_YSize = FontY = Scr->RastPort.Font->tf_YSize;
FontX = Scr->RastPort.Font->tf_XSize;
OffX = Scr->WBorLeft;
OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
if ( width && height ) {
if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
goto UseTopaz;
if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
goto UseTopaz;
}
return;
UseTopaz:
Font->ta_Name = (STRPTR)"topaz.font";
FontX = FontY = Font->ta_YSize = 8;
}
int SetupScreen( void )
{
if ( ! ( Scr = LockPubScreen( PubScreenName )))
return( 1L );
ComputeFont( 0, 0 );
if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
return( 2L );
return( 0L );
}
void CloseDownScreen( void )
{
if ( VisualInfo ) {
FreeVisualInfo( VisualInfo );
VisualInfo = NULL;
}
if ( Scr ) {
UnlockPubScreen( NULL, Scr );
Scr = NULL;
}
}
int OpenHelpWindow( void )
{
struct NewGadget ng;
struct Gadget *g;
UWORD lc, tc;
UWORD wleft = HelpLeft, wtop = HelpTop, ww, wh;
ComputeFont( HelpWidth, HelpHeight );
ww = ComputeX( HelpWidth );
wh = ComputeY( HelpHeight );
if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
if ( ! ( g = CreateContext( &HelpGList )))
return( 1L );
for( lc = 0, tc = 0; lc < Help_CNT; lc++ ) {
CopyMem((char * )&HelpNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
ng.ng_VisualInfo = VisualInfo;
ng.ng_TextAttr = Font;
ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
ng.ng_Width = ComputeX( ng.ng_Width );
ng.ng_Height = ComputeY( ng.ng_Height);
HelpGadgets[ lc ] = g = CreateGadgetA((ULONG)HelpGTypes[ lc ], g, &ng, ( struct TagItem * )&HelpGTags[ tc ] );
while( HelpGTags[ tc ] ) tc += 2;
tc++;
if ( NOT g )
return( 2L );
}
if ( ! ( HelpMenus = CreateMenus( HelpNewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
return( 3L );
LayoutMenus( HelpMenus, VisualInfo, GTMN_NewLookMenus, TRUE, TAG_DONE );
/* ^^^^^^^^^^^^^^^^^^^^^^^^ ADDED */
HelpZoom[0] = HelpLeft;
HelpZoom[1] = HelpTop;
if ( HelpWdt )
HelpZoom[2] = TextLength( &Scr->RastPort, (UBYTE *)HelpWdt, strlen((char *)HelpWdt )) + 80;
else
HelpZoom[2] = 80L;
HelpZoom[3] = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
if ( ! ( HelpWnd = OpenWindowTags( NULL,
WA_Left, wleft,
WA_Top, wtop,
WA_Width, ww + OffX + Scr->WBorRight,
WA_Height, wh + OffY + Scr->WBorBottom,
WA_IDCMP, STRINGIDCMP|LISTVIEWIDCMP|BUTTONIDCMP|CHECKBOXIDCMP|INTEGERIDCMP|CYCLEIDCMP|IDCMP_MENUPICK|IDCMP_CLOSEWINDOW|IDCMP_CHANGEWINDOW|IDCMP_REFRESHWINDOW,
WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
WA_Gadgets, HelpGList,
WA_Title, HelpWdt,
WA_ScreenTitle, ""VERSION_STR"",
WA_Zoom, HelpZoom,
WA_AutoAdjust, TRUE,
/* ADDED ------> */ WA_NewLookMenus, TRUE,
TAG_DONE )))
return( 4L );
SetMenuStrip( HelpWnd, HelpMenus );
GT_RefreshWindow( HelpWnd, NULL );
return( 0L );
}
void CloseHelpWindow( void )
{
if ( HelpMenus ) {
ClearMenuStrip( HelpWnd );
FreeMenus( HelpMenus );
HelpMenus = NULL; }
if ( HelpWnd ) {
CloseWindow( HelpWnd );
HelpWnd = NULL;
}
if ( HelpGList ) {
FreeGadgets( HelpGList );
HelpGList = NULL;
}
}